<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>登录 - 驴妈妈流立方</title>
		<meta name="description" content="User login page" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<link rel="icon" href="${rc.contextPath}/assets/avatars/logo.ico" type="image/x-icon" />
		<link rel="shortcut icon" href="${rc.contextPath}/assets/avatars/logo.ico" type="image/x-icon" />
		<link rel="bookmark" href="${rc.contextPath}/assets/avatars/logo.ico" type="image/x-icon" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/font-awesome/4.2.0/css/font-awesome.min.css" />
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/jquery-ui.custom.min.css" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/jquery.gritter.min.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/fonts/fonts.googleapis.com.css" />
		<!-- BootstrapValidator -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrapValidator.min.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
		<!-- ace settings handler -->
		<script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery.2.1.1.min.js"></script>
		<script src="${rc.contextPath}/assets/js/bootstrap.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery-ui.custom.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="${rc.contextPath}/assets/js/bootbox.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery.gritter.min.js"></script>
		<script src="${rc.contextPath}/assets/js/spin.min.js"></script>
		<!-- ace scripts -->
		<script src="${rc.contextPath}/assets/js/ace-elements.min.js"></script>
		<script src="${rc.contextPath}/assets/js/ace.min.js"></script>
		<!-- validator scripts -->
		<script src="${rc.contextPath}/assets/js/bootstrapValidator.min.js"></script>
		<!-- user scripts -->
		<script src="${rc.contextPath}/assets/js/user/base.js"></script>
	</head>

	<body class="login-layout light-login">
		<div class="main-container">
			<div class="main-content">
				<div class="row">
					<div class="col-sm-10 col-sm-offset-1">
						<div class="login-container">
							<div class="center">
								<h1>
									<i class="ace-icon fa"><img src="${rc.contextPath}/assets/avatars/logo.png" style="width:30px;"/></i>
									<span class="red"></span>
									<span class="pink" id="id-text2">驴妈妈流立方</span>
								</h1>
								<h4 class="pink" id="id-company-text">&copy; 驴妈妈</h4>
							</div>

							<div class="space-6"></div>

							<div class="position-relative">
								<div id="login-box" class="login-box visible widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header pink lighter bigger">
												<i class="ace-icon fa fa-coffee pink"></i>
												请输入用户名和密码进行登录
											</h4>

											<div class="space-6"></div>

											<form id="loginForm" class="form-horizontal" role="form" action="${rc.contextPath}/user/index" method="POST">
												<input type="hidden" id="mainFrame" name="mainFrame" value="">
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" id="username" class="form-control" placeholder="用户名" />
															<i class="ace-icon fa fa-user"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" id="password" class="form-control" placeholder="密码" />
															<i class="ace-icon fa fa-lock"></i>
														</span>
													</label>
													
													<!-- <label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" id="imgCode" class="form-control" placeholder="验证码" style="width: 170px;" />
															<img src="${rc.contextPath}/kaptcha.jpg" id="loginImgCode" class="ace-icon" style="height: 32px; right: -3px;" />
														</span>
													</label> -->

													<div class="space"></div>

													<div class="clearfix">
														<button type="button" id="loginBtn" class="width-35 pull-right btn btn-sm btn-pink">
															<i class="ace-icon fa fa-key"></i>
															<span class="bigger-110">登录</span>
														</button>
													</div>

													<div class="space-4"></div>
												</fieldset>
											</form>
										</div>
									</div><!-- /.widget-body -->
								</div><!-- /.login-box -->
							</div><!-- /.position-relative -->
						</div>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div><!-- /.main-content -->
		</div><!-- /.main-container -->
		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			$(document).ready(function(event) {
				if(parent.document.location.href.indexOf("/user/index")!=-1){
					parent.document.location.href="${rc.contextPath}/page/login";
				}
				/* $("#loginImgCode").on('click', function(e) {
					$(this).attr('src', '${rc.contextPath}/kaptcha.jpg?' + Math.floor(Math.random()*100) ); 
				}); */

				$('#loginBtn').on('click', function(e) {
					var username = $('#username').val();
					var password = $('#password').val();
					/* var imgCode = $('#imgCode').val(); */
					if (isEmpty(username) || isEmpty(password)) {
						showMsg('用户名或密码不能为空！');
						return false;
					}
					/* if(isEmpty(imgCode)) {
						showMsg('图形验证码不能为空！');
						return false;
					} */

					$.ajax({
						url : '${rc.contextPath}/user/login',
						data : {
							username : username,
							password : password/* ,
							imgCode : imgCode */
						},
						type : 'POST',
						dataType : 'json',
						success : function(result) {
							if (result.code == '1') {
								//window.location.href = "${rc.contextPath}/user/index";
								var url = result.url;
								if(url != null){
									$("#mainFrame").val(url.requestURI);
								}
								$("#loginForm").submit();
							} else {
								/* $("#loginImgCode").trigger("click"); */
								showMsg(result.message);
							}
						}
					});
				});
				
				$(window).keydown(function(event){
					  if(event.keyCode=="13") {
						  $('#loginBtn').click();
					  }
					});
			});
		</script>
	</body>
</html>